// import 'dart:ffi';

/// token : "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwaG9uZSI6IjEzNzk3MDM5MzIxIiwiZXhwIjoxNjU5NDMxODgxLCJpYXQiOjE2NTg4MjcwODEsInVzZXJJZCI6IjE1NDcxNzEyNzE1NTU1MjI1ODIifQ.MkxyALmhv36x_0Vny4nK8WmD9BjxbI1D5zPmiFpTsGM"
/// userInfo : {"id":"1547171271555522582","nickName":"会员.eyh52","phone":"13797039321","avatar":null,"status":1,"createTime":1658827081,"updateTime":null,"totalLikes":null,"totalFans":null,"totalAttention":null}

class UserEntity {
  UserEntity({
      this.token, 
      this.userInfo,});

  UserEntity.geneUser() {
    userInfo = UserInfo.fromJson(null);
  }
  UserEntity.fromJson(dynamic json) {
    token = json['token'];
    // token = "772580999098";
    // userInfo = json['userInfo'] != null ? UserInfo.fromJson(json['userInfo']) : null;
    userInfo = UserInfo.fromJson(json);

  }
  setUserInfo(Map<String,dynamic> json) {
    // this.userInfo!.id = json['userId'];
    // this.userInfo!.nickName = json['nick_name'];
    // this.userInfo!.avatar = json['avatar'];
    userInfo = userInfo?.fromJson2(json);
  }

  String? token;
  UserInfo? userInfo;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['token'] = token;
    if (userInfo != null) {
      map['userInfo'] = userInfo?.toJson();
    }
    return map;
  }

}

/// id : "1547171271555522582"
/// nickName : "会员.eyh52"
/// phone : "13797039321"
/// avatar : null
/// status : 1
/// createTime : 1658827081
/// updateTime : null
/// totalLikes : null
/// totalFans : null
/// totalAttention : null

class UserInfo {
  UserInfo({
      this.id, 
      this.nickName, 
      this.phone, 
      this.avatar, 
      this.status, 
      this.createTime, 
      this.updateTime, 
      this.totalLikes, 
      this.totalFans, 
      this.totalAttention,});

  UserInfo.fromJson(dynamic json) {
    id = json==null?"2123": json["userInfo"]["id"];
    nickName = json==null?"2123": json["userInfo"]["nickName"];
    phone = "21312311231";
    avatar = json==null?"2123": json["userInfo"]["avatar"];
    // avatar = "http://192.168.204.139:8000/my123/1.jpg?Content-Disposition=attachment%3B%20filename%3D%221.jpg%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20240320%2F%2Fs3%2Faws4_request&X-Amz-Date=20240320T095838Z&X-Amz-Expires=432000&X-Amz-SignedHeaders=host&X-Amz-Signature=e3c5951d597964e0df0c4693b0f1a4deec1fac4f2c15f345ac10c8ede689f6d5";
    status = 1;
    createTime = 2027877878777;
    updateTime = "2099-8-9";
    totalLikes = 7980000;
    totalFans = 666666;
    totalAttention = "89000000";
  }
  String? id;
  String? nickName;
  String? phone;
  dynamic avatar;
  int? status;
  int? createTime;
  dynamic updateTime;
  dynamic totalLikes;
  dynamic totalFans;
  dynamic totalAttention;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['nickName'] = nickName;
    map['phone'] = phone;
    map['avatar'] = avatar;
    map['status'] = status;
    map['createTime'] = createTime;
    map['updateTime'] = updateTime;
    map['totalLikes'] = totalLikes;
    map['totalFans'] = totalFans;
    map['totalAttention'] = totalAttention;
    return map;
  }

  fromJson2(Map<String, dynamic> json) {
    // String user_id = String.fromCharCodes([...json['user_id']]);;
    int zid = json['userId'];

    String userId = zid.toString() ;
    id = userId;
    nickName = json['nickName'];

    avatar = json['avatar'];
    return this;
  }

}